/*************************************************************
     copyright (c) Southwest JiaoTong University 
	                    School of Information and Scientific Technology
     filename: linklist.h
	 description: some important link list algorithm
	 current version: 1.0
	 author: Bryan.Li
	 date: 2012.8.5
**************************************************************/
#ifndef _LINKLIST_H
#define _LINKLIST_H
#include <cstdlib>
template<class T> class Stack;
template<class T>
class StackNode
{
	friend class Stack<T>;
public:
	StackNode(T i=0,StackNode<T> *p=NULL):data(i),next(p) {}
	~StackNode();
private:
	T data;
	StackNode<T> *next;
};

template<class T>
class Stack
{
private:
	StackNode<T> *top;
public:
	Stack():top(NULL){}
	~Stack()
	{
		makeEmpty();
	}
	T pop();
	T GetTop();
	void Push(const T & item);
	bool isEmpty()
	{
		return top==NULL;
	}
	void makeEmpty();
	void printStack();
};


#endif